package com.cgc.venus.server.monitor.controller;

import com.cgc.venus.server.core.bean.response.VenusResponse;
import com.cgc.venus.server.core.bean.response.VenusResponseStatus;
import com.cgc.venus.server.core.exception.VenusException;
import com.cgc.venus.server.core.heapster.model.ResultSet;
import com.cgc.venus.server.monitor.bean.MonitorQuery;
import com.cgc.venus.server.monitor.bean.MonitorResult;
import com.cgc.venus.server.monitor.inter.MonitorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * Created by 业哥 on 2017/11/8.
 */
@Api(value = "监控", description = "监控对应服务的api")
@RequestMapping("/monitor-admin")
@RestController
public class MonitorController {
    @Autowired
    private MonitorService monitorServiceImpl;

    @ApiOperation("监控查询")
    @RequestMapping(value = "/monitor", method = RequestMethod.GET)
    @ResponseBody
    public VenusResponse<Object> monitor(@RequestParam("monitorType") String monitorType,@RequestParam("monitorObject") String monitorObject,@RequestParam("metricsType") String metricsType,@RequestParam("times") String times,@RequestParam("nodeNames") String nodeNames,@RequestParam("namespaceName") String namespaceName,@RequestParam("podNames") String podNames) throws VenusException {
        MonitorQuery monitorQuery=new MonitorQuery(monitorType,monitorObject,metricsType,times,nodeNames,namespaceName,podNames);
        MonitorResult monitorResult=monitorServiceImpl.monitorQuery(monitorQuery);
        VenusResponse<Object> response=new VenusResponse<Object>(VenusResponseStatus.OK,"",monitorResult);
        return response;
    }
}